public class StartPoint {

	enum ParserLib {
		JSONP, FANGIONG, GSON, JACKSON, FASTJSON
	}

	public static void main(String[] args) {
		testAllFiles("JSONP");
		testAllFiles("FANGIONG");
		testAllFiles("GSON");
		testAllFiles("JACKSON");
		testAllFiles("FASTJSON");
		testAllFiles("JSONP");
		testAllFiles("FANGIONG");
		testAllFiles("GSON");
		testAllFiles("JACKSON");
		testAllFiles("FASTJSON");
	}

	public static long testAllFiles(String type) {
		long used = 0;
		for (int i = 1; i <= 20; ++i) {
			used += test(type, String.format("%02d", 1), 100);
		}
		System.out.println(type + ": " + used);
		return used;
	}

	public static long test(String type, String file, int numberOfRun) {
		ParserLib parserLib = ParserLib.valueOf(type.toUpperCase());
		String fullFileLocation = String.format("jsondata/%s.json", file);
		Parser parser = null;
		switch (parserLib) {
			case JSONP:
				parser = new JsonpParser(fullFileLocation);
				break;
			case FANGIONG:
				parser = new FangiongParser(fullFileLocation);
				break;
			case GSON:
				parser = new GsonParser(fullFileLocation);
				break;
			case JACKSON:
				parser = new JacksonParser(fullFileLocation);
				break;
			case FASTJSON:
				parser = new FastjsonParser(fullFileLocation);
		}
		return parser.run(numberOfRun);
	}
}
